<?php
namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Auth\Authenticatable;

class User extends Model implements HasMedia, JWTSubject, AuthenticatableContract
{

    use HasMediaTrait, Authenticatable;

    protected $table = 'users';

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims()
    {
        return [];
    }

    public function getSexAttribute($value)
    {
        return $value === 1 ? '男' : '女';
    }

    public function oauthUser(){
        return $this->hasMany('App\Model\OauthUser', 'user_id');
    }
}